package com.address.entity;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import com.address.util.PrimaryKeyGenerator;

public class Contact implements Serializable {
	public static final String ID = "id";
	public static final String NAME = "name";
	public static final String SEX = "sex";
	public static final String ADDRESS = "address";
	public static final String TELEPHONE = "telephone";
	public static final String EMAIL = "email";
	
	public final static List<String> fields;
	static{
		fields = new LinkedList<String>();
		fields.add(NAME);
		fields.add(SEX);
		fields.add(ADDRESS);
		fields.add(TELEPHONE);
		fields.add(EMAIL);	
	}
	
	private String id = null;	
	private String name = null;
	private String sex = null;
	private String address = null;
	private String telephone = null;
	private String email = null;

	public Contact(){
		this.id = PrimaryKeyGenerator.getUUId();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}



	public String getTelephone() {
		return telephone;
	}


	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}



	public String getEmail() {
		return email;
	}

	


	public void setEmail(String email) {
		this.email = email;
	}



	@Override
	public String toString() {
		return "Contact [name=" + name + ", sex=" + sex + ", address=" + address + ", telephone=" + telephone
				+ ", email=" + email + "]";
	}

	public String getFileName() {
		// TODO Auto-generated method stub
		return id;
	}
	public  boolean isEmpty(){
		if(this.getAddress()==null&&this.getEmail()==null
		&&this.getSex()==null&&this.getName()==null
		&&this.getTelephone() == null){
			return true;
		}
		return false;
	}

	public  boolean contains(Contact son){
		if(!this.isEmpty()^son.isEmpty()){
			return true;
		}else if(this.isEmpty()){
			return false;
		}else if(son.isEmpty()){
			return true;
		}
		
		if(this.getAddress() != null){
			if(son.getAddress() != null){
				if(!(this.getAddress().equals(son.getAddress()))){
					return false;
				}
				return false;
			}
		}
		
		if(this.getEmail() != null){
			if(son.getEmail() != null){
				if(!(this.getEmail().equals(son.getEmail()))){
					return false;
				}
				return false;
			}
		}
		
		if(this.getSex() != null){
			if(son.getSex() != null){
				if(!(this.getSex().equals(son.getSex()))){
					return false;
				}
				return false;
			}
		}
		
		if(this.getName() != null){
			if(son.getName() != null){
				if(!(this.getName().equals(son.getName()))){
					return false;
				}
				return false;
			}
		}
		
		if(this.getTelephone() != null){
			if(son.getTelephone() != null){
				if(!(this.getTelephone().equals(son.getTelephone()))){
					return false;
				}
				return false;
			}
		}
		
		return true;
		
	}
}
